<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>100.0020.浏览器原理-20-async_await-02</title>
    <script>

      // window.onload = function(){
      //   console.log('js执行完成 , window context 退出');
      // }
    </script>
</head>
<body>
    <div>
        <div id="showRespDataId"></div>
        <hr><br><hr>
        <div id="showAllNet"></div>
        <button id="testXieChengId">点击测协程</button>
        <button id="testRenderId">点击渲染文字</button>
    </div>
</body>
<script>
function* genDemo() {
    console.log(" 开始执行第一段 ")
    yield 'generator 1'
 
    console.log(" 开始执行第二段 ")
    yield 'generator 2'
 
    console.log(" 执行结束 ")
    return 'generator 3'  // 若不写return，则返回值即为 undefined
}

var gen = genDemo()
console.log(gen);

console.log(gen.next());

var btn = document.getElementById('testXieChengId')
btn.onclick = function(e){
  console.log(gen.next());
}

var cnt = 1;
var btn02 = document.getElementById('testRenderId')
btn02.onclick = function(){
  var d01 = document.getElementById('showAllNet')
  cnt++;
  d01.innerHTML = 'toggle counts : '+ cnt ;
}
// console.log(gen.next());
// console.log(gen.next());
// console.log(gen.next());

</script>
</html>